//
// Created by sundagao on 25-8-13.
//

#ifndef ANIMAL_H
#define ANIMAL_H

#include <QObject>
#include <QString>

class Animal : public QObject
{
    Q_OBJECT
    // 动物种类属性
    Q_PROPERTY(QString species READ species WRITE setSpecies NOTIFY speciesChanged)
    // 年龄属性
    Q_PROPERTY(int age READ age WRITE setAge NOTIFY ageChanged)
    // 体重属性
    Q_PROPERTY(double weight READ weight WRITE setWeight NOTIFY weightChanged)
public:
    enum Specie
    {
        Lion,
        Tiger
    };

    explicit Animal(QObject *parent = nullptr);

    // Getter方法
    QString species() const;
    int age() const;
    double weight() const;

    // Setter方法
    void setSpecies(const QString &species);
    void setAge(int age);
    void setWeight(double weight);

signals:
    // 属性变化信号
    void speciesChanged();
    void ageChanged();
    void weightChanged();

private:
    QString m_species;
    int m_age;
    double m_weight;
};

#endif // ANIMAL_H
